<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>07_面试题1</title>
</head>
<body>
<script>
// 1、测试代码1
var name = "The Window"
var object = {
    name: "My Object",
    getNameFunc: function() {
        return function() {
            console.log(this)
            return this.name
        }
    }
}
alert(object.getNameFunc()()) // The Window

// 2、测试代码2
var name2 = "The Window"
var object2 = {
    name2: "My Object",
    getNameFunc2: function() {
        var that = this;
        console.log(this)
        return function() {
            return that.name2
        }
    }
}
alert(object2.getNameFunc2()()) // My Object
</script>
</body>
</html>